﻿
using hcache;
using hentity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace hwms {
    /**
   *┌────────────────────────────────────────────────┐
   *│　描    述：LocSelect                                                    
   *│　作    者：sgj                                              
   *│　版    本：1.0                                              
   *│　创建时间：2021/9/8 16:59:49                        
   *└────────────────────────────────────────────────┘
   **/
  public   class SingleLocSelect :LocSelect {
        public override CoreWhLoc moveSelect(CoreWhLoc src,IDbConnection Connection,IDbTransaction transaction) {
            List<CoreWhLoc> locList = CoreUtil.getLoc4SelectIn(src.areaId ,src.moveGroup ,Connection ,transaction);
            return select(locList ,src.goodsDiff);
        }

        public override bool canWork(long meId ,long beforeId ,List<long> relyTask) {
            BaseTask me = TaskCacheDB.getTaskById(meId).t;
            CTaskDto<BaseTask> before = TaskCacheDB.getTaskById(beforeId);
            if( me.className == before.t.className ) {
                return before.t.status >= 5;
            }
            return false;

        }
        public override CoreWhLoc select(List<CoreWhLoc> locList ,long goodDiff) {

            int len = locList.Count();
            for( int i = 0;i < len;i++ ) {
                CoreWhLoc shallow = locList[i];
                if( shallow.countStock == 0 ) {
                    return shallow;
                }
            }
            return null;

        }
    }
}
